import axios from 'axios'
import { Toast} from 'antd-mobile';
const getNewShareList = () => {
    return (dispatch) => {
        axios.get('./json/NewShare.json').then(res => {
            dispatch({
                type: 'DET_INDEX_SHARE',
                payload: {
                    newShareList: res
                }
            })
        })
    }
}

const getSwiperList = () => {
    return (dispatch) => {
        Toast.loading('Loading...', 0, null,true);
        axios.get('http://rap2api.taobao.org/app/mock/267061/swipercont').then(res => {
            // console.log(res)
            // this.setState({
            //     dataImg: res.data.list
            // })
            dispatch({
                type:'GET_SWIPER_LIST',
                payload:res.data.list
            })
            Toast.hide();
        }).catch(err => {
            console.log(err)
            Toast.hide();
        })
    }
}
const getSwiperShopp = (num) =>{
    Toast.loading('Loading...', 0, null,true);
    return (dispatch)=>{
        axios.get('http://rap2api.taobao.org/app/mock/267061/shoppdata'+num
         
        ).then(res=>{
            dispatch({
                type:'GTE_SWIPER_SHOOP',
                payload:res.data.list
            })
            Toast.hide();
        }).catch(err=>{
            Toast.hide();
            console.log(err)
        })
    }
}
export {getSwiperList,getSwiperShopp}